<?php
/************************************************************************/
/* PHP-NUKE: Ajax Modules Administration System Version v0.4            */
/* ==========================================================           */
/*                                                                      */
/* Copyright (c) 2006 by aman                                           */
/* http://www.aman.38.com                                               */
/************************************************************************/
/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (!defined('ADMIN_FILE')) {
	die ("Access Denied");
}
require_once("mainfile.php");
require_once("admin/language/lang-$currentlang.php");

global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if ($row['radminsuper'] == 1) {

function Update($data) {
		global $prefix, $db, $admin_file;

		$arr=explode('|',urldecode($data));
		/*foreach($arr as $k => $v){
			list($k2,$v2)=explode('=',$v);
				${$k2} = $v2;
		}*/
		
		$mid = intval($arr[0]);
		$active = $arr[1];
		$inmenu = ($arr[2]);
		$custom_title = mysql_real_escape_string($arr[3]);
		$view = intval($arr[4]);
		
		
		if ($view != 1) { $mod_group = 0; }
		
		$sql="update " . $prefix . "_modules set custom_title='$custom_title', view='$view', inmenu='$inmenu', mod_group='$mod_group',active='$active' where mid='$mid'";
		$result = $db->sql_query($sql);
//return $sql;
}

function ModulesSw($cat_id){
		global $prefix, $db, $admin_file;
		list($id,$active,$inhome) = explode('|',$cat_id);
			if($active > 0)$activeDB = 0;
			else $activeDB = 1;

			$rs = $db->sql_query("UPDATE " . $prefix . "_modules SET active ='$activeDB' WHERE  mid ='$id'");

				$row = $db->sql_fetchrow($db->sql_query("SELECT active from " . $prefix . "_modules WHERE  mid ='$id'"));
				$activeSW = intval($row['active']);
			
			if($activeSW==0)
			{
				$title=_INACTIVE;
				$activeimg="stop.gif";
				$sw=0;
			}else
			{ 
				$title=_ACTIVE;
				$activeimg="active.gif";
				$sw=1;
			}

			$img ="<img title=\"$title\" onclick=\"getModulesSw($id,$sw,$inhome)\" height=\"16\" alt=\"$title\" width=\"16\" border=\"0\" src=\"images/$activeimg\" onmouseover=\"this.style.cursor='hand';\" />";
			if($myDebug > 0)$img .="($id,$sw,$inhome)";
			if($inhome > 0)$img .="<img src=\"images/key.gif\" alt=\""._INHOME."\" title=\""._INHOME."\" border=\"0\" width=\"17\" height=\"17\">";

		return array($id,$img,$activeSW);
}

function setModuleToHome($mid) {
		global $prefix, $db, $admin_file;
		$mid = intval($mid);

			$row3 = $db->sql_fetchrow($db->sql_query("SELECT title from " . $prefix . "_modules where mid='$mid'"));
			$title = $row3['title'];
			$active = 1;
			$view = 0;
			$res = $db->sql_query("update " . $prefix . "_main set main_module='$title'");
			$res2 = $db->sql_query("update " . $prefix . "_modules set active='$active', view='$view' where mid='$mid'");
	}
	
require_once('includes/dd_files/Sajax.php');
    
    	$sajax_request_type = "POST";
    	sajax_init();
    	sajax_export("ModulesSw","Main","Update","setModuleToHome");
    	
    	sajax_handle_client_request();

include ("header.php");
		OpenTable();
		echo "<center><address title='Administration Center' onclick=\"expand('GraphicAdmin','item1');\"  onmouseout=\"this.style.color = 'black';\" onmouseover=\"this.style.color = 'red';this.style.cursor='pointer';\"><img id=\"item1\" src=\"images/plus.gif\" /> Administration Center</address></center>";
		CloseTable();
		
echo "<div id=\"GraphicAdmin\" style=\"display:none;\">";
		GraphicAdmin();
echo "</div>";
		OpenTable();
		echo "<center><a href=\"$admin_file.php?op=modules\"><font class=\"title\">AJAX " . _MODULESADMIN . " v0.4</font></a></center>" 
    ."<br><center><img src='images/s_S_OKAY.gif' border='0'>Compatible with Firefox, Opera and IE !!";
		CloseTable();
		
?>
<style type="text/css">
#header address:hover {color: white; 
background-color:#e76931; text-decoration: underline;} /* mouse over link */
	att.hover{color:Red; }
	h2.rollover {color:black}  /* initialize properties on class */
	tr.text1 { background-color:#FFEEC8; color:#000000;  }
	tr.textb { background-color:#ffe000; color:#000000; font-weight:bold; }
</style>
        <script>
        <?
        sajax_show_javascript();
        ?>
        
        function getModulesSw_cb(list) {
        	var aid = 'active'+list[0];
        	var img = list[1];
        	var activeSw = list[2];
              document.getElementById(aid).innerHTML = img;
                             
					var swArea = 'activeSw'+list[0];
        	var strTarget = document.getElementById(swArea).innerHTML;
					var start= strTarget.indexOf("RowSp('")+7;
					var end= strTarget.indexOf("');");

					var arr = (strTarget.substring(start,end)).split("','");
					var myArr = arr[1].split("|");
					
					var odata = "";
					var ndata = "";
			    for(var i=0;i< myArr.length;i++){
			        var vn = myArr[i];
			        odata = odata+vn;     
			        ndata = (i == 1)?ndata+activeSw:ndata+vn;		        	
			        if(i < 5){
			        	ndata = ndata + "|";
			        	odata = odata + "|";
			        }
			    }

					document.getElementById(swArea).innerHTML = strTarget.replace(odata,ndata );
					
					var rowIndex = document.getElementById("divTMP").value;
					//if(rowIndex>0){
						RowClose(rowIndex,"recall");

						ndata = ndata.replace('\\',"");
						ndata = ndata.replace("&#039;","'");
						insertRowSp(list[0],ndata,'tblBasic1b',rowIndex,'info');
				  //}
        }
        function getModulesSw(mId,active,inhome){
        	var pid=mId + '|' + active + '|' + inhome;
        	x_ModulesSw(pid, getModulesSw_cb);
        }

				function getUpdate(FormId) {
					var fvalue = unescape(getFormValues(LockForm(FormId)));
					var fdata = fvalue.split('&');
					//alert(fvalue);
					//alert(fvalue);
					fdata=fdata[0]+'|'+fdata[1]+'|'+fdata[2]+'|'+fdata[3]+'|'+fdata[4];
					//alert(fdata);
					x_Update(fdata, getLoad);
				}

        function getInHome(mId) {
               x_setModuleToHome(mId, getLoad);
        }
        
        function getMain_cb(server) {
                document.getElementById("main_div").innerHTML = server;
        }

        function getLoad(sql) {
                x_Main(getMain_cb);
                if(sql)document.getElementById("info").innerHTML = sql;
        }

var submitStr = '<?echo ""._SAVECHANGES."";?>';

var labelStr = new Array();
labelStr[0] = '<?echo ""._CUSTOMMODNAME."";?>';
labelStr[1] = '<?echo ""._VIEWPRIV."";?>';
labelStr[2] = '<?echo ""._SHOWINMENU."";?>';
labelStr[3] = '<?echo ""._ACTIVE."";?>';
labelStr[4] = '';

var viewprivStr = new Array();
viewprivStr[0] = '<?echo ""._MVALL."";?>';
viewprivStr[1] = '<?echo ""._MVUSERS."";?>';
viewprivStr[2] = '<?echo ""._MVADMIN."";?>';
viewprivStr[3] = '<?echo ""._SUBUSERS."";?>';

function expand(thistag,el){
   styleObj=document.getElementById(thistag).style;
   if(styleObj.display=='none'){
   	styleObj.display='';
   	imgsrc="images/minus.gif";
   }else {
   	styleObj.display='none';
   	imgsrc="images/plus.gif";
   	}
   	
  document.getElementById(el).src=imgsrc;
}
// mredkj.com
// 2005-08-15 - created
// 2006-05-14 - updated
function appendRow(tblId)
{
	var tbl = document.getElementById(tblId);
	var newRow = tbl.insertRow(tbl.rows.length);
	var newCell = newRow.insertCell(0);
	newCell.innerHTML = 'Hello World!';
}
function deleteLastRow(tblId)
{
	var tbl = document.getElementById(tblId);
	if (tbl.rows.length > 0) tbl.deleteRow(tbl.rows.length - 1);
}

function RowClose(rowIndex,recall)
{
	back(rowIndex);
	document.getElementById("tblBasic1b").deleteRow(rowIndex);
	document.getElementById("divTMP").value="";
}

function change(thistag){
   styleObj=document.getElementById('roll'+thistag).style;styleObj.color="red";
   //styleObj=document.getElementById('roll'+thistag).style;styleObj.fontWeight="bold";
}
function back(thistag){
   styleObj=document.getElementById('roll'+thistag).style;styleObj.color="black";
}

function insertRowSp2(mId,dataArr,tblId,rowIndex, txtError)
{
	var chk = document.getElementById('divTMP').value;
	if(chk>0)insertRowSp(mId,dataArr,tblId,rowIndex, txtError,1);
}

function insertRowSp(mId,dataArr,tblId,rowIndex, txtError,holdBox)
{
	var tbl = document.getElementById(tblId);
	var chk = document.getElementById('divTMP').value;
	
	if(chk>0){
		tbl.deleteRow(chk);
		back(chk);
		if(chk == rowIndex && holdBox != 1) { 
			document.getElementById('divTMP').value = "";
			return;
		}
	}

	document.getElementById('divTMP').value = rowIndex;
	dataArr = unescape(dataArr.replace(/\+/g, " "));
	
	change(rowIndex);
	
	var rowID = document.getElementById("divTMP").value;

	try {
		var newRow = tbl.insertRow(rowIndex);
		var newCell = newRow.insertCell(0);
		var myarr = dataArr.split("|");
		var custom_title = myarr[0];

		newCell.setAttribute('colSpan', '6');
		newCell.innerHTML ='<div id="divED" align="center"></div>';
		//document.getElementById("divED").innerHTML = "edForm:<strong>"+custom_title +"</strong><img src='images/close.gif' onclick='RowClose("+rowID+");'>";
		//document.getElementById("divCLOSE").innerHTML = "<img src='images/close.gif' onclick='RowClose("+rowID+");'>";

		t = document.createElement("TABLE");
		t.setAttribute("width","100%");
		
		tbody = document.createElement("TBODY");
		t_row=document.createElement("TR");

		t_cella=document.createElement("TD");
		t_cella.setAttribute("width","30%");
		var txt=" ";
		t_cella.innerHTML = txt;
		t_row.appendChild(t_cella);
		
		t_cellb=document.createElement("TD");
		var txt="edit: <strong><font color='red'>"+ custom_title +"</font></strong>";
		t_cellb.innerHTML = txt;
		//t_cell.appendChild(txt);
		t_row.appendChild(t_cellb);

		t_cellc=document.createElement("TD");
		t_cellc.setAttribute("width","30%");
		var txt="<img title='Close this EditBox' src='images/close.gif' onclick='RowClose("+rowID+");' onmouseover=\"this.style.cursor='pointer';\">";
		t_cellc.innerHTML = txt;
		//t_cell.appendChild(txt);
		t_row.appendChild(t_cellc);
		
		tbody.appendChild(t_row);
    t.appendChild(tbody);
    //document.getElementById("divED").innerHTML = t;
    document.getElementById("divED").appendChild(t);
    
		MakeForm("divED",dataArr);

	} catch (ex) {
		document.getElementById(txtError).value = ex;
	}
}

function changeContent(myTable,rowNum,cellNum,mystr)
{
var x=document.getElementById(myTable).rows[rowNum].cells
x[cellNum].innerHTML=mystr
}


function insertRow(tblId, txtIndex, txtError)
{
	var tbl = document.getElementById(tblId);
	var rowIndex = document.getElementById(txtIndex).value;
	try {
		var newRow = tbl.insertRow(rowIndex);
		var newCell = newRow.insertCell(0);
		newCell.innerHTML = 'Hello World! insert';
	} catch (ex) {
		document.getElementById(txtError).value = ex;
	}
}
function deleteRow(tblId, txtIndex, txtError)
{
	var tbl = document.getElementById(tblId);
	var rowIndex = document.getElementById(txtIndex).value;
	try {
		tbl.deleteRow(rowIndex);
	} catch (ex) {
		document.getElementById(txtError).value = ex;
	}
}
function formTest(FormId) {
var fvalue = getFormValues(LockForm(FormId));
  alert(fvalue);
  //document.getElementById("divTEST").innerHTML = fvalue;
}
function getField (form, fieldName) {
  if (!document.all)
    return form[fieldName];
  else  // IE has a bug not adding dynamically created field 
        // as named properties so we loop through the elements array 
    for (var e = 0; e < form.elements.length; e++)
      if (form.elements[e].name == fieldName)
        return form.elements[e];
  return null;
} 
function addField (form, fieldType, fieldName, fieldValue,fldSize) {
  if (document.getElementById) {
    var input = document.createElement('INPUT');
      if (document.all) { // what follows should work 
                          // with NN6 but doesn't in M14
        input.type = fieldType;
        input.name = fieldName;
        input.value = fieldValue;
      }
      else if (document.getElementById) { // so here is the
                                          // NN6 workaround
        input.setAttribute('type', fieldType);
        input.setAttribute('name', fieldName);
        input.setAttribute('value', fieldValue);
      }

    if (fldSize > 0)input.setAttribute("size",fldSize);
    if (fldSize == "button")input.onclick = function(){getUpdate("edForm");};

    form.appendChild(input);
  }
}

function getFormValues(fobj) {
    var str='';
    for(var i=0;i< fobj.elements.length;i++){
        var vn = fobj.elements[i].name;
        if(vn!="active" && vn!="inmenu" && vn!="submitED") 
        str+= escape(fobj.elements[i].value)+'&';
    }//mvmcv
    str=str.substr(0,(str.length-1));
    return str;
}    

function LockForm(FormId){
var cells = document.getElementsByTagName("form"); 
	for (var i = 0; i < cells.length; i++) { 
	    status = cells[i].getAttribute("name"); 
	    if ( status == FormId) { 
	        var j = i;
	    }
	}
	return document.getElementsByTagName("form")[j];
}

function swObjValues(fobj,oname,ovalue){

    var str='';
    for(var i=0;i< fobj.elements.length;i++){
        var vn = fobj.elements[i].name;
        if(fobj.elements[i].name== oname) 
        fobj.elements[i].value=ovalue;
    }
}

function pass(fldID , fldValue) {
	var target ="my"+fldID;
	swObjValues(LockForm("edForm"),target,fldValue);
}

function addRadioField (form, fieldType, fldID, fldValue,optchecked) {

  if (document.getElementById) {
			try{
					if(optchecked == "checked" ){
					var rdo = document.createElement('<input type="radio" name="' + fldID + '" value="' + fldValue + '" checked/>');
					}else{
					 var rdo = document.createElement('<input type="radio" name="' + fldID + '" value="' + fldValue + '"/>');
					 }
			}catch(err){
			var rdo = document.createElement('input');
			rdo.setAttribute('type','radio');
			rdo.setAttribute('name',fldID);
			
			if(optchecked == "checked" )rdo.setAttribute('checked', true);
			}

			rdo.onclick = function(){pass(fldID , fldValue);};
			form.appendChild(rdo);
  }
}

function changeContent()
{
var x=document.getElementById('myTable').rows[0].cells
x[0].innerHTML="NEW CONTENT"
}

function MakeForm(myObj,dataArr) {
   var mybody=document.getElementById(myObj);
   // creates an element whose tag name is TABLE
   mytable = document.createElement("TABLE");
   // creates an element whose tag name is TBODY
   mytablebody = document.createElement("TBODY");
   // creating all cells
   
		var myarr = dataArr.split("|");
		var custom_title = myarr[0];
		var active = myarr[1];
		var view = myarr[2];
		var mod_group = myarr[3];
		var inmenu = myarr[4];
		var mid = myarr[5];

		if(inmenu== 1){
		 menuchk1="checked";
		 menuchk0="";
		}else{
		 menuchk1="";
		 menuchk0="checked";
		}

		if(active== 1){
		 chk1="checked";
		 chk0="";
		}else{
		 chk1="";
		 chk0="checked";
		}

		switch (view)
		{
		case "0":
			sel0 = "selected";
			sel1 = "";
			sel2 = "";
			sel3 = "";
			break
		case "1":
			sel1 = "selected";
			sel0 = "";
			sel2 = "";
			sel3 = "";
			break
		case "2":
			sel2 = "selected";
			sel1 = "";
			sel3 = "";
			sel0 = "";
			break
		case "3":
			sel3 = "selected";
			sel1 = "";
			sel2 = "";
			sel0 = "";
			break
		}

		
   for(j=0;j<5;j++) {
   // creates an element whose tag name is TR
   mycurrent_row=document.createElement("TR");
   for(i=0;i<2;i++) {
		mycurrent_cell=document.createElement("TD");
		if(i==1){ 
				if(j== 0)addField (mycurrent_cell,"text","custom_title",custom_title,"30");
				if(j== 1){
/*secondSelect=document.createElement("select");
secondSelect.setAttribute("name","view");
secondSelect.setAttribute("id","view");
secondOpt1=document.createElement("option");
secondOpt1.setAttribute("id","twoStart");
secondOpt1.setAttribute("value",sel0);
secondOpt1.appendChild(document.createTextNode(viewprivStr[0]));
secondOpt2=document.createElement("option");
secondOpt2.setAttribute("id","bl");
secondOpt2.setAttribute("value",sel1);
secondOpt2.appendChild(document.createTextNode(viewprivStr[1]));
secondOpt3=document.createElement("option");
secondOpt3.setAttribute("id","RH");
secondOpt3.setAttribute("value",sel2);
secondOpt3.appendChild(document.createTextNode(viewprivStr[2]));
secondOpt4=document.createElement("option");
secondOpt4.setAttribute("id","br");
secondOpt4.setAttribute("value",sel3);
secondOpt4.appendChild(document.createTextNode(viewprivStr[3]));
secondSelect.appendChild(secondOpt1);
secondSelect.appendChild(secondOpt2);
secondSelect.appendChild(secondOpt3);
secondSelect.appendChild(secondOpt4);
mycurrent_cell.appendChild(secondSelect);*/
					mycurrent_cell.innerHTML="<select name='view'>" +
					"<option value='0' "+sel0 +">"+viewprivStr[0]+"</option>" +
					"<option value='1' "+sel1 +">"+viewprivStr[1]+"</option>" +
					"<option value='2' "+sel2 +">"+viewprivStr[2]+"</option>" +
					"<option value='3' "+sel3 +">"+viewprivStr[3]+"</option>" +
					"</select>";
					}

				if(j == 2){ 
             addRadioField (mycurrent_cell, "radio", "inmenu", "1",menuchk1);     
             apText(mycurrent_cell," Yes");
             addRadioField (mycurrent_cell, "radio", "inmenu", "0",menuchk0);
             apText(mycurrent_cell," No");
         }
				if(j == 3){ 
             addRadioField (mycurrent_cell, "radio", "active", "1",chk1);
             apText(mycurrent_cell," Yes");
             addRadioField (mycurrent_cell, "radio", "active", "0",chk0);
             apText(mycurrent_cell," No");
         }
        if(j == 4){
        		addField (mycurrent_cell,"button","submitED",submitStr,"button"); 
        }
   }else apText(mycurrent_cell,labelStr[j]);

                // appends the cell TD into the row TR
                mycurrent_row.appendChild(mycurrent_cell);
            }
            // appends the row TR into TBODY
            mytablebody.appendChild(mycurrent_row);
        }
        // appends TBODY into TABLE
        mytable.appendChild(mytablebody);
        mytable.setAttribute("border","2");
        mytable.setAttribute("name","tblED");
        mytable.setAttribute("width","70%");

  var f=document.createElement('form');
  f.setAttribute('name','edForm');
  f.setAttribute('action','#');
  f.setAttribute('method','post');
  
  var hmid=document.createElement("input"); 
  hmid.setAttribute('type', "hidden"); 
  hmid.setAttribute('name', 'mid'); 
  hmid.setAttribute('value',mid); 
  f.appendChild(hmid); 

  var myactive=document.createElement("input"); 
  myactive.setAttribute('type', "hidden"); 
  myactive.setAttribute('name', 'myactive'); 
  myactive.setAttribute('value',active); 
  f.appendChild(myactive); 

  var myinmenu=document.createElement("input"); 
  myinmenu.setAttribute('type', "hidden"); 
  myinmenu.setAttribute('name', 'myinmenu'); 
  myinmenu.setAttribute('value',inmenu); 
  f.appendChild(myinmenu); 
  
  f.appendChild(mytable); 
  mybody.appendChild(f);
  
    }
function apText(cell,myText){   
   currenttext=document.createTextNode(myText);
   cell.appendChild(currenttext);
}

window.onload = getLoad;
</script>


<div id="info"></div>
<div id="main_div"><center><img src='images/loading.gif'> loading...</center></div>
<?include("footer.php");?>

<?
} else {
	echo "Access Denied";
}


function OpenTable3(){
$content =  "<table width=\"100%\" align=\"center\" border=\"1\">";
$content .=  "    <tbody>";
$content .=  "        <tr>";
$content .=  "            <td align=\"center\">";
    return $content;
}

function CloseTable3(){
$content =  ";</td>
            </tr>
        </tbody>
    </table>";
    return $content;
}

function Main() {
    global $prefix,$db, $admin_file;

	
    $handle=opendir('modules');
    $modlist = "";
    while ($file = readdir($handle)) {
	if ( (!ereg("[.]",$file)) ) {
		$modlist .= "$file ";
	}
    }
    closedir($handle);
    $modlist = explode(" ", $modlist);
    sort($modlist);
    for ($i=0; $i < sizeof($modlist); $i++) {
	if(!empty($modlist[$i])) {
	    $row = $db->sql_fetchrow($db->sql_query("SELECT mid from " . $prefix . "_modules where title='$modlist[$i]'"));
	    $mid = intval($row['mid']);
	    if (empty($mid)) {
		$db->sql_query("insert into " . $prefix . "_modules values (NULL, '$modlist[$i]', '$modlist[$i]', '0', '0', '', '1', '0', '')");
	    }
	}
    }
    $result2 = $db->sql_query("SELECT title from " . $prefix . "_modules");
    while ($row2 = $db->sql_fetchrow($result2)) {
	$title = $row2['title'];
	$a = 0;
	$handle=opendir('modules');
	while ($file = readdir($handle)) {
	    if ($file == $title) {
		$a = 1;
	    }
	}
	closedir($handle);
	if ($a == 0) {
	    $db->sql_query("delete from " . $prefix . "_modules where title='$title'");
	}
    }
    
    $content =  "<div id=\"divTMP\"></div>";

    OpenTable3();
    $content .=  "<br><center><font class=\"option\">" . _MODULESADDONS . "</font>"
		."<address title='Help' onclick=\"expand('helptext','item2');\"  onmouseout=\"this.style.color = 'black';\" onmouseover=\"this.style.color = 'red';this.style.cursor='pointer';\"><img id=\"item2\" src=\"images/plus.gif\" /> Help</address>"
		."<p id=\"helptext\" style=\"display:none;color:red\">"
		."<font class=\"content\">" . _MODULESACTIVATION . "</font><br><br>"
		."" . _MODULEHOMENOTE . "<br><br>" . _NOTINMENU . "</p>"

	."<form action=\"".$admin_file.".php\" method=\"post\">"
        ."<table border=\"1\" align=\"center\" width=\"90%\" id=\"tblBasic1b\"><tr><td align=\"center\" bgcolor=\"$bgcolor2\">"
	."<b>"._TITLE."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._CUSTOMTITLE."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._STATUS."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._VIEW."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._GROUP."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._FUNCTIONS."</b></td></tr>";
    $main_m = $db->sql_fetchrow($db->sql_query("SELECT main_module from " . $prefix . "_main"));
    $main_module = $main_m['main_module'];
    $result3 = $db->sql_query("SELECT mid, title, custom_title, active, view, inmenu, mod_group from " . $prefix . "_modules order by title ASC");
    

    $tri=2;
    while ($row3 = $db->sql_fetchrow($result3)) {
	$mid = intval($row3['mid']);
	$title = $row3['title'];
	$custom_title = $row3['custom_title'];
	$active = intval($row3['active']);
	$view = intval($row3['view']);
	$inmenu = intval($row3['inmenu']);
	$mod_group = intval($row3['mod_group']);
	$chkhome="($mid,$active,0)";
	$homemark="($mid,$active,1)";
	$confirm2 = "" . _TO . " [ $title ] ?";
	$dataArr=htmlspecialchars("$custom_title|$active|$view|$mod_group|$inmenu|$mid", ENT_QUOTES);
	if (empty($custom_title)) {
	    $custom_title = ereg_replace("_"," ",$title);
	    $db->sql_query("update " . $prefix . "_modules set custom_title='$custom_title' where mid='$mid'");
	}
	if ($active == 1) {
				$active = "<img src=\"images/active.gif\" alt=\""._ACTIVE."\" title=\""._ACTIVE."\" border=\"0\" width=\"16\" height=\"16\" onclick=\"getModulesSw($mid,$active,0)\" onmouseover=\"this.style.cursor='pointer';\">";

	    $act = 0;
	} else {
				$active = "<img src=\"images/stop.gif\" alt=\""._INACTIVE."\" title=\""._INACTIVE."\" border=\"0\" width=\"16\" height=\"16\" onclick=\"getModulesSw($mid,$active,0)\" onmouseover=\"this.style.cursor='pointer';\">";

	    $act = 1;
	}
	if (empty($custom_title)) {
	    $custom_title = ereg_replace("_", " ", $title);
	}
	if ($view == 0) {
	    $who_view = _MVALL;
	} elseif ($view == 1) {
	    $who_view = _MVUSERS;
	} elseif ($view == 2) {
	    $who_view = _MVADMIN;
	} elseif ($view == 3) {
	    $who_view = _SUBUSERS;
   } elseif ($view > 3) {
       $who_view = _MVGROUPS;
	}
	if ($title != $main_module AND $inmenu == 0) {
	    	
	    $title = "[ <big><strong>&middot;</strong></big> ] $title";
	}
	
	if ($title == $main_module) {
	    $old_m = "[ $title ]";
	    $title = "<b>$title</b>";
	    $custom_title = "<b>$custom_title</b>";
				
				$active = str_replace($chkhome,$homemark,$active)."<img src=\"images/key.gif\" alt=\""._INHOME."\" title=\""._INHOME."\" border=\"0\" width=\"17\" height=\"17\">";
				$who_view = "<b>$who_view</b>";
				$puthome = "<img src=\"images/key_x.gif\" alt=\""._INHOME."\" title=\""._INHOME."\" border=\"0\" width=\"17\" height=\"17\">";

	    $background = "bgcolor=\"$bgcolor2\"";
	    
	} else {
				$confirm1 = "" . _SURETOCHANGEMOD . " ";

				$confirm = "$confirm1 $confirm2";
				$puthome = "<img src=\"images/key.gif\" alt=\""._PUTINHOME."\" title=\""._PUTINHOME."\" border=\"0\" width=\"17\" height=\"17\" onClick=\"if(confirm('$confirm ?')) getInHome($mid);\" onmouseover=\"this.style.cursor='pointer';\">";

	    $background = "";
	}
	if ($mod_group != 0) {
	    $grp = $db->sql_fetchrow($db->sql_query("SELECT name FROM ".$prefix."_groups WHERE id='$mod_group'"));
	    $mod_group = $grp['name'];
	} else {
	    $mod_group = _NONE;
	}

			$content .=  "<tr id=\"roll{$tri}\" class=\"rollover\"><td $background>&nbsp;$title</td>
			<td align=\"center\" $background>".stripslashes($custom_title)."</td>
			<td align=\"center\" $background><div id='active{$mid}' onclick=\"insertRowSp2('$mid','$dataArr','tblBasic1b','$tri','info');\">$active </div></td>
			<td align=\"center\" $background>$who_view</td>
			<td align=\"center\" $background>$mod_group</td>
			<td align=\"center\" $background nowrap><div id='activeSw{$mid}'>&nbsp; <img title=\"Edit\" onclick=\"insertRowSp('$mid','$dataArr','tblBasic1b','$tri','info');\" height=\"17\" alt=\"Edit\" width=\"17\" border=\"0\" src=\"images/edit.gif\" onmouseover=\"this.style.cursor='pointer';\" />  $puthome &nbsp;</div></td></tr>";
			
			$tri ++;
    }
    $content .=  "</table></form></center>";
    CloseTable3();

		$content .=  "<div align=\"right\"><a href=\"http://www.aman.38.com/phpnuke/\" target=\"_bank\"><b>www.aman.38.com</a> &copy; ajax Modules_Administration v0.4</b></div>";


    $confirm1="" . _SURETOCHANGEMOD . "";
    $confirm_last1="" . _SURETOCHANGEMOD . " $old_m ";
    $content = str_replace($confirm1,$confirm_last1,$content);
    
return $content;
}
?>